import { constant, AttachmentElement } from "./constant";
/**
 * @description parse elem html
 * @author wangfupeng
 */

import { IDomEditor, SlateDescendant, SlateElement } from "@wangeditor/editor";

function parseHtml(elem: Element, children: SlateDescendant[], editor: IDomEditor): SlateElement {
  const value = elem.getAttribute("data-value") || "1212";
  return {
    type: constant.type,
    value,
    children: [{ text: "" }]
  } as AttachmentElement;
}

const parseHtmlConf = {
  selector: `div[data-w-e-type="${constant.type}"]`,
  parseElemHtml: parseHtml
};

export default parseHtmlConf;
